#pragma once
#include <iostream>
#include <string>
#include <fstream>

class file_util
{
public:
    static bool read(const std::string &filename,std::string &body)
    {
        std::ifstream file;
        //打开文件
        file.open(filename.c_str(), std::ios::in | std::ios::binary);
        if(!file)
        {
            std::cout << filename << "Open failed!" << std::endl;
            return false;
        }
        //计算文件大小
        file.seekg(0, std::ios::end);
        body.resize(file.tellg());
        file.seekg(0, std::ios::beg);
        file.read(&body[0], body.size());
        if(file.good() == false)
        {
            std::cout << filename << "Read failed!" << std::endl;
            file.close();
            return false;
        }
        file.close();
        return true;
        
    }
};